package com.cskaoyan.javase.oop1._3memory;

/**
 * 三个对象的内存图，其中有两个引用指向同一个对象。
 *
 * @since 17:01
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo {
    public static void main(String[] args) {
        Student s = new Student();
        // s和s2引用应该指向同一个对象
        Student s2 = s;
        Student s3 = new Student();
        System.out.println(s == s2);
        System.out.println(s == s3);
    }
}

class Student {
    int age;

    public void eat() {
        System.out.println("马上就可以吃晚饭了!");
    }
}
